home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1993 May / Info-Mac_II_May_1993.to_.sit / Info-Mac II (May 1993).toast / Unix / eudora-offline-reader.shar < prev    next >
Internet Message Format  |  1993-01-10  |  23KB

  1. Date: Sun, 20 Sep 1992 19:16:42 -0400 
  2. From: kkirksey@world.std.com (Ken B Kirksey)
  3. Subject: Eudora As An Offline Reader 
  4.  
  5.  
  6. This archive contains a short Unix program and document explaining how to use
  7. Eudora as an offline UNIX mail reader.  If you want to use Eudora, but don't
  8. have a TCP/IP connection to your mac or access to a slip server, this file is for you.  
  9.  
  10. The program (udora.c) and the document are both in the beta stage. I've gotten
  11. the program to compile on a SparcStation, but I'd like to know how it compiles
  12. on other unix boxes.  Any feedback is welcome and appreciated.
  13.  
  14.                                   Ken
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of shell archive."
  23. # Contents:  udora.c udora.readme
  24. # Wrapped by kkirksey@world on Sun Sep 20 19:11:03 1992
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f udora.c -a "${1}" != "-c" ; then 
  27.   echo shar: Will not over-write existing file \"udora.c\"
  28. else
  29. echo shar: Extracting \"udora.c\" \(11642 characters\)
  30. sed "s/^X//" >udora.c <<'END_OF_udora.c'
  31. X/*******************************************************************************
  32. X* udora.c                                                       by Ken Kirksey *
  33. X* Version 1.0b1                                                    20 Sep 1992 *
  34. X*                                                                              *
  35. X* This program takes the Out file generated by Eudora and automatically parses *
  36. X* out and mails each message in the file.  Consult the Readme file that came   *
  37. X* with this source file for complete details on it's use.                      *
  38. X*                                                                              *
  39. X* Eudora )1990 by the University of Illinois Board of Trustees.                *
  40. X* Eudora was written by Steve Dorner                                           *
  41. X*                                                                              *
  42. X* This program )1992 Ken Kirksey.  It may be modified for your personal use    *
  43. X* only.  Do not distribute an modified versions of this program.               *
  44. X*******************************************************************************/
  45. X#include <stdio.h>
  46. X#include <string.h>
  47. X
  48. X#ifdef THINKC
  49. X#include <console.h>
  50. X#endif
  51. X
  52. X/*=============================================================================+
  53. X|                           Macros and Constants                               |
  54. X+=============================================================================*/
  55. X#define MAIL_TEMP_FILE  "udora.tmp"
  56. X#define SIG_FILE        ".signature"
  57. X#define TRUE            1
  58. X#define FALSE           0
  59. X
  60. X/*=============================================================================+
  61. X|                                Variables                                     |
  62. X+=============================================================================*/
  63. XFILE    *infile,
  64. X        *outfile,
  65. X        *sigfile;
  66. X    
  67. Xchar    buffer1 [120],
  68. X        *charPtr,
  69. X        toAddress[120],
  70. X        subject[180];
  71. X        
  72. Xint     isSigfile;
  73. X        
  74. X
  75. X/*=============================================================================+
  76. X|                                  MAIN                                        |
  77. X+=============================================================================*/
  78. Xmain (argc, argv)
  79. Xint argc;
  80. Xchar **argv;
  81. X{
  82. X
  83. X#ifdef THINKC
  84. X    argc = ccommand (&argv);
  85. X#endif
  86. X    
  87. X    /*-------------------------------------------------------------------------+
  88. X    | Report error if they didn't give a mail file name.                       |
  89. X    +-------------------------------------------------------------------------*/
  90. X    if (argc < 2)
  91. X    {
  92. X        fprintf (stderr, "\n Useage: eudora <filename>");
  93. X        exit (-1);
  94. X    }
  95. X    
  96. X    /*-------------------------------------------------------------------------+
  97. X    | Open input mail file.                                                    |
  98. X    +-------------------------------------------------------------------------*/
  99. X    if ( (infile = fopen (argv[1], "r")) == NULL)
  100. X    {
  101. X        perror ("Error opening input file");
  102. X        exit (-1);
  103. X    }
  104. X    
  105. X    /*-------------------------------------------------------------------------+
  106. X    | Open Temp file.                                                          |
  107. X    +-------------------------------------------------------------------------*/
  108. X    if ( (outfile = fopen ("eudora.tmp", "w")) == NULL)
  109. X    {
  110. X        perror ("Error opening udora temp file");
  111. X        exit (-1);
  112. X    }
  113. X    
  114. X    /*-------------------------------------------------------------------------+
  115. X    | Check for the existence of the signature file.                           |
  116. X    +-------------------------------------------------------------------------*/
  117. X    if ( (sigfile = fopen (SIG_FILE, "r")) == NULL)
  118. X        isSigfile = FALSE;
  119. X    else
  120. X        isSigfile = TRUE;
  121. X    
  122. X    fclose (sigfile);
  123. X    
  124. X    
  125. X    /*-------------------------------------------------------------------------+
  126. X    | Priming read.  Read in destination address from mail header.             |
  127. X    +-------------------------------------------------------------------------*/
  128. X    fgets (buffer1, 119, infile);
  129. X    fgets (buffer1, 119, infile);
  130. X    strcpy ( toAddress, (buffer1+4));
  131. X
  132. X    /*-------------------------------------------------------------------------+
  133. X    | Handle addresses of the form "username@domain (Real Name)"               |
  134. X    +-------------------------------------------------------------------------*/
  135. X    if (  (charPtr = strchr (toAddress, '(')) != NULL) 
  136. X        *charPtr = '\0';
  137. X
  138. X    /*-------------------------------------------------------------------------+
  139. X    | Handle addresses of the form "Real Name <username@domain>"               |
  140. X    +-------------------------------------------------------------------------*/
  141. X    else if (  (charPtr = strchr (toAddress, '<')) != NULL)
  142. X    {
  143. X        strcpy (toAddress, (charPtr+1));
  144. X        charPtr = strchr (toAddress, '>');
  145. X        *charPtr = '\0';
  146. X    }
  147. X    /*-------------------------------------------------------------------------+
  148. X    | Handle a plain-jane normal type address.                                 |
  149. X    +-------------------------------------------------------------------------*/
  150. X    else
  151. X        *(toAddress + strlen (toAddress)-1) = '\0';
  152. X
  153. X    /*-------------------------------------------------------------------------+
  154. X    | Read in subject and eat the rest of the header lines.                    |
  155. X    +-------------------------------------------------------------------------*/
  156. X    fgets (buffer1, 119, infile);
  157. X    fgets (buffer1, 119, infile);
  158. X    strcpy ( subject, (buffer1+9) );
  159. X    *(subject + strlen (subject)-1) = '\0';
  160. X    fgets (buffer1, 119, infile);
  161. X    fgets (buffer1, 119, infile);
  162. X    fgets (buffer1, 119, infile);
  163. X    fgets (buffer1, 119, infile);
  164. X    
  165. X    /*-------------------------------------------------------------------------+
  166. X    | Main Loop Time!  We read in each message until we hit the header of the  |
  167. X    | following message.  Then we mail the message.                            |
  168. X    +-------------------------------------------------------------------------*/
  169. X    while (!feof (infile))
  170. X    {
  171. X        /*---------------------------------------------------------------------+
  172. X        | If the line starts with "From:" then we've hit the header of the     |
  173. X        | next message.                                                        |
  174. X        +---------------------------------------------------------------------*/
  175. X        if ( (buffer1[0] == 'F') && (buffer1[1] == 'r') &&
  176. X             (buffer1[2] == 'o') && (buffer1[3] == 'm') )
  177. X        {
  178. X            /*-----------------------------------------------------------------+
  179. X            | Close the temp file.  Mail the current message and post a status |
  180. X            | report to stdout.                                                |
  181. X            +-----------------------------------------------------------------*/
  182. X            fclose (outfile);
  183. X                
  184. X            sprintf (buffer1, "mailing \"%s\" to %s", subject, toAddress);
  185. X            fprintf (stdout, "%s\n", buffer1);
  186. X
  187. X            sprintf (buffer1, "mail -s \"%s\" %s < eudora.tmp", subject,
  188. X                         toAddress);
  189. X            system (buffer1);
  190. X                         
  191. X            /*-----------------------------------------------------------------+
  192. X            | Remove the temp file, create a new one and open it.              |
  193. X            +-----------------------------------------------------------------*/
  194. X            remove ("eudora.tmp");
  195. X                
  196. X            if ( (outfile = fopen ("eudora.tmp", "w")) == NULL)
  197. X            {
  198. X                perror ("Error opening output file");
  199. X                exit (-1);
  200. X            }
  201. X                
  202. X            /*-----------------------------------------------------------------+
  203. X            | Read in address.                                                 |
  204. X            +-----------------------------------------------------------------*/
  205. X            fgets (buffer1, 119, infile);
  206. X            strcpy ( toAddress, (buffer1+4));
  207. X
  208. X            /*-----------------------------------------------------------------+
  209. X            | Handle addresses of the form "username@domain (Real Name)"       |
  210. X            +-----------------------------------------------------------------*/
  211. X            if (  (charPtr = strchr (toAddress, '(')) != NULL) 
  212. X                *charPtr = '\0';
  213. X
  214. X            /*-----------------------------------------------------------------+
  215. X            | Handle addresses of the form "Real Name <username@domain>"       |
  216. X            +-----------------------------------------------------------------*/
  217. X            else if (  (charPtr = strchr (toAddress, '<')) != NULL)
  218. X            {
  219. X                strcpy (toAddress, (charPtr+1));
  220. X                charPtr = strchr (toAddress, '>');
  221. X                *charPtr = '\0';
  222. X            }
  223. X            /*-----------------------------------------------------------------+
  224. X            | Handle a plain-jane normal type address.                         |
  225. X            +-----------------------------------------------------------------*/
  226. X            else
  227. X                *(toAddress + strlen (toAddress)-1) = '\0';
  228. X                
  229. X            /*-----------------------------------------------------------------+
  230. X            | Read in Subject and eat rest of mail header lines.               |
  231. X            +-----------------------------------------------------------------*/
  232. X            fgets (buffer1, 119, infile);
  233. X            fgets (buffer1, 119, infile);
  234. X                
  235. X            strcpy ( subject, (buffer1+9) );
  236. X            *(subject + strlen (subject)-1) = '\0';
  237. X            fgets (buffer1, 119, infile);
  238. X            fgets (buffer1, 119, infile);
  239. X            fgets (buffer1, 119, infile);
  240. X                
  241. X        }
  242. X
  243. X        /*---------------------------------------------------------------------+
  244. X        | If the line starts with "~s", then we insert the signature here.     |
  245. X        +---------------------------------------------------------------------*/
  246. X        else if ( (buffer1[0] == '~') && (buffer1[1] == 's') )
  247. X        {
  248. X            if (isSigfile)
  249. X            {
  250. X                if ( (sigfile = fopen (SIG_FILE, "r")) == NULL)
  251. X                {
  252. X                    perror ("Error opening signature file");
  253. X                    exit (-1);
  254. X                }
  255. X                
  256. X                fgets (buffer1, 119, sigfile);
  257. X                while (!feof (sigfile))
  258. X                {
  259. X                    fputs (buffer1, outfile);
  260. X                    fgets (buffer1, 119, sigfile);
  261. X                }
  262. X                fclose (sigfile);
  263. X            }
  264. X        }
  265. X    
  266. X        /*---------------------------------------------------------------------+
  267. X        | This is just a line in the mail message. Write it to the temp file.  |
  268. X        +---------------------------------------------------------------------*/
  269. X        else
  270. X            fprintf (outfile, "%s", buffer1);
  271. X            
  272. X        fgets (buffer1, 119, infile);
  273. X        
  274. X    }
  275. X    
  276. X    /*-------------------------------------------------------------------------+
  277. X    | We've reache the end of the mail file.  Close it and mail the last       |
  278. X    | message.                                                                 |
  279. X    +-------------------------------------------------------------------------*/
  280. X    fclose (outfile);
  281. X    sprintf (buffer1, "mailing \"%s\" to %s", subject, toAddress);
  282. X    fprintf (stdout, "%s\n", buffer1);
  283. X
  284. X    sprintf (buffer1, "mail -s \"%s\" %s < eudora.tmp", subject, toAddress);
  285. X    system (buffer1);
  286. X    
  287. X    remove ("eudora.tmp");
  288. X    
  289. X}
  290. END_OF_udora.c
  291. if test 11642 -ne `wc -c <udora.c`; then
  292.     echo shar: \"udora.c\" unpacked with wrong size!
  293. fi
  294. # end of overwriting check
  295. fi
  296. if test -f udora.readme -a "${1}" != "-c" ; then 
  297.   echo shar: Will not over-write existing file \"udora.readme\"
  298. else
  299. echo shar: Extracting \"udora.readme\" \(9124 characters\)
  300. sed "s/^X//" >udora.readme <<'END_OF_udora.readme'
  301. XUsing Eudora As An Offline UNIX Mail Reader
  302. X                  
  303. Xby Ken Kirksey
  304. X(kkirksey@world.std.com)
  305. X                                 
  306. X
  307. X
  308. XINTRODUCTION
  309. X
  310. X    The first time I saw Eudora, I thought it was the neatest thing since 
  311. X    sliced bread.  One of my friends worked for the academic computing 
  312. X    department at the university I was attending (Auburn U., for those who 
  313. X    care), and he had Eudora running on the Mac in his office.  I though to
  314. X    myself, "Now this is the way to read my Internet mail!"  Unfortunately, I 
  315. X    found out that to use Eudora you had to have a TCP/IP connection to the
  316. X    network (which my friend had) or access to a SLIP server (which we didn't
  317. X    have).  So, I resigned myself to using "mail."
  318. X
  319. X    Then I graduated and moved, and all of the sudden I had to make a long
  320. X    distance call to get my mail (New Horrors! New Horrors!).  Needless to say,
  321. X    interative reading with "mail" wouldn't cut it.  So I took to compressing 
  322. X    and downloading my mail spool file so I could read all my mail offline.  
  323. X    A great idea, except that all I had was a raw spool file that I could 
  324. X    peruse with a text editor.  Not very pretty.
  325. X
  326. X    Then I remembered Eudora.  As fate would have it, Eudora could read the
  327. X    raw mail spool files.  So I could read my message in a nice way.  But 
  328. X    replying to messages, or sending new ones, was a pain.  So I wrote a 
  329. X    little C program that automated the process.  Now I was back up to speed.
  330. X
  331. X    So here I am, sharing my experience and that program with ya'll (southern
  332. X    for you all :)  I've tried everything I'll cover in here, so it's all been
  333. X    play-tested, so to speak.  If you have any problems with the program, or 
  334. X    these instructions, feel free to drop me a note at kkirksey@world.std.com.
  335. X    
  336. X    Note that throughout this document "Eudora" refers to the Mac program, 
  337. X    while "udora" (unix Eudora) refers to the UNIX side program.
  338. X
  339. X
  340. XGETTING EUDORA
  341. X
  342. X    The first thing you need to do is get a copy of Eudora.  The program 
  343. X    itself is available at info-mac in the comm directory.  This archive 
  344. X    doesn't include the documentation, however.  You don't NEED the 
  345. X    documentation to get up and running with Eudora, but I highly recommend 
  346. X    getting it.  The full Eudora release used to be available at 
  347. X    ux1.cso.uiuc.edu in the mac/eudora directory, but it's gone now.  A quick 
  348. X    archie search told me that it was available at orion.oac.uci.edu in the
  349. X    directory /ntslib/mac/mail/eudora.1.2/NTS.dist.  If anyone out there 
  350. X    knows where Eudora's new official home is, please drop me a note and I'll 
  351. X    include it in a later version of these here docs.
  352. X
  353. X
  354. XSETTING UP EUDORA
  355. X
  356. X    Once you've installed Eudora, you need to set it up so that it will work 
  357. X    using it as an offline reader.  
  358. X
  359. X    First go to the "Configuration..." option under the "Special" menu.  Make 
  360. X    sure that the "Communications Toolbox" radio button is checked.  If 
  361. X    "MacTCP" is checked, it will scream at you since you don't have MacTCP 
  362. X    installed.  If you do, why are you reading this? :)
  363. X
  364. X    Then go to the "Switches..." option under the "Special" menu.  Under 
  365. X    "Composition:" make sure that the "Immediate Send" checkbox is NOT 
  366. X    checked.  This lets you queue up outgoing messages.  Under "When 
  367. X    Quitting:" make sure that "Compact Mailboxes" is checked.
  368. X
  369. X    Composing and replying to messages is pretty straightforward.  Consult 
  370. X    the Eudora documentation if you have any problems.  I'd advise reading 
  371. X    through it in any event.
  372. X
  373. X
  374. XGETTING YOUR MAIL TO YOUR MAC
  375. X
  376. X    Under UNIX, your mail is usually stored in the /usr/spool/mail directory 
  377. X    in a file that is named the same as your login.  For instance, mine is 
  378. X    stored in /usr/spool/mail/kkirksey.  You want to move this file out of 
  379. X    the /usr/spool/mail directory and on to your mac.  Basically, here's what
  380. X    you do:
  381. X    
  382. X    1) Move the spool file to your home directory with 
  383. X         
  384. X           mv /usr/spool/mail/<username> .
  385. X       
  386. X       You want to move it rather than copy it, because if you copy it, you 
  387. X       aren't removing the messages you read from the spool file.  It'll just 
  388. X       keep growing, and growing, and growing....
  389. X       
  390. X       If your mail isn't kept in /usr/spool/mail, check with your sysadmin
  391. X       to see where it is located.
  392. X     
  393. X    2) Transfer your mail file to your mac via your favorite file transfer
  394. X       protocol.
  395. X       
  396. X    If your communication program supports scripting, you can write a short 
  397. X    script to automate this procedure.
  398. X    
  399. X    As an option, you may want to compress the file with the UNIX "compress"
  400. X    command.  This gives you a .Z file that you can uncompress on your Mac 
  401. X    using the MacCompress program (avaliable at info-mac).  If you call long 
  402. X    distance to get your mail, this step will save you mucho $.
  403. X    
  404. X
  405. XIMPORTING YOUR MAIL INTO EUDORA
  406. X
  407. X    Now that you've got your mail to your mac, you've got two options.  The 
  408. X    first is just to drop the file into the Eudora Folder in your System 
  409. X    Folder.  Eudora can read it just like one of it's own files.  There's a 
  410. X    problem with doing it this way.  What if you haven't finished reading 
  411. X    all your messages in you spool file (kkirksey for me) ?  Well, you could 
  412. X    give your new spool file another name (kkirksey1 for instance).  But now
  413. X    you've got a couple of mail files where you could have only one.
  414. X    
  415. X    A better solution (what I do) is to concatenate your new mail on to the "In"
  416. X    file in the Eudora Folder.  That way, all your mail is kept in one place, and 
  417. X    you don't have to worry about what you have and haven't read. t.  I use 
  418. X    Unity (available on info-mac) to concatenate the files together.
  419. X    
  420. X    To read your mail, just select "In" from the "Mailbox" menu in Eudora.  
  421. X    Since you've modified the "In" file, it will ask you if you want to 
  422. X    create a new table of contents for that file.  Tell it Ok.
  423. X    
  424. X
  425. XSENDING NEW MESSAGES OR REPLIES
  426. X
  427. X    First of all, you need to have a copy of the udora.c program in your UNIX 
  428. X    account.  To compile the program, just type
  429. X    
  430. X          cc udora.c -o udora
  431. X          
  432. X    at the prompt.  You can remove the udora.c file after you've compiled it.
  433. X    
  434. X    I'm assuming that you've read the Eudora docs and have already composed 
  435. X    some new messages or replies.  All outgoing messages are stored in the 
  436. X    "Out" file in the Eudora Folder.  Upload this file to your UNIX account.
  437. X    Be sure that you have compacted the mailboxes before you do this.  
  438. X    Eudora inserts some redundant header information in the Out file that 
  439. X    seems to disappear when you compact your mailboxes.  udora won't crash 
  440. X    if you don't do this, but you will get some strange messages.
  441. X    
  442. X    Once you've uploaded "Out" to your account, just type
  443. X    
  444. X          udora Out
  445. X          
  446. X    at the prompt to mail your messages.  It's as simple as that.  After 
  447. X    you've successfully mailed your outgoing messages, be sure to empty 
  448. X    the "Out" mailbox in Eudora so you don't send them again.
  449. X    
  450. X    If you quit Eudora while you have messages in the Out mailbox, it will 
  451. X    ask you if you want to send the messages now or just quit.  Always click 
  452. X    "Just Quit."  It will get very confused if you tell it to send them.
  453. X    
  454. X
  455. XSIGNATURES
  456. X
  457. X    Even if you chose the signature option in Eudora, it doesn't include it
  458. X    with your message in the "Out" file, so it doesn't work for our 
  459. X    purposes.  I've included a signature option in udora to make up for 
  460. X    this.  Keep your signature in a file named ".signature" in your home 
  461. X    directory.  If you want udora to append your signature to a message, 
  462. X    just put ~s on a line by itself at the end of a message.  Don't put 
  463. X    any spaces in front of ~s, or udora won't recoginze it as a signature 
  464. X    command.
  465. X    
  466. X
  467. XSOME THINGS WORK, SOME DON'T
  468. X
  469. X    Another Eudora feature that doesn't work for our purposes.  Eudora 
  470. X    attaches the files as it's sending the message via TCP/IP, so I doesn't 
  471. X    include the attached file in the "Out" file.  I'm thinking about adding
  472. X    a file attach feature to udora.
  473. X    
  474. X    The Eudora nicknames feature doesn't work either, since it doesn't 
  475. X    expand the nicknames in the Out file.  This is another possible 
  476. X    enhancement to udora.
  477. X    
  478. X    udora currently doesn't recognize the cc: and bcc: lines in the header, 
  479. X    so you bcc and cc's will be ignored.  Yet another possible new feature.  
  480. X    
  481. X    If you want to see any or all of these features added to udora, drop me 
  482. X    a note.  If there's enough interest, I'll probably do it.
  483. X
  484. XTIPS
  485. X
  486. X    If you subscribe to bunches of internet digests like I do, and like to 
  487. X    save your messages to text files, go to the "Switches..." option under 
  488. X    the "Special" menu and make sure that "Guess Paragraphs" is NOT 
  489. X    checked.  If it is, it will sometimes munge your documents when you save 
  490. X    them.
  491. X    
  492. X    
  493. XCOMMMENTS, BUG REPORTS, etc.
  494. X
  495. X    All welcome.  Tell me what you think of this doc and udora.  Just drop
  496. X    me a note at kkirksey@world.std.com.
  497. END_OF_udora.readme
  498. echo shar: Missing newline added to \"udora.readme\"
  499. if test 9124 -ne `wc -c <udora.readme`; then
  500.     echo shar: \"udora.readme\" unpacked with wrong size!
  501. fi
  502. # end of overwriting check
  503. fi
  504. echo shar: End of shell archive.
  505. exit 0
  506.  
  507.  
  508.